'use strict'

const path = require('path')

function resolve (dir) {
  return path.join(__dirname, dir)
}
module.exports = {
  outputDir: 'dist',
  assetsDir: '',
  publicPath: process.env.VUE_APP_FILE_API,
  productionSourceMap: false,
  devServer: {
    disableHostCheck: true,
    host: 'localhost',
    port: 8080,
    open: false,
    proxy: {
      '/pharmacyapitest': {
        target: process.env.VUE_APP_UPLOAD_API,
        changeOrigin: true,
        pathRewrite: {
          '^/pharmacyapitest': ''
        }
      }
    },
    overlay: {
      warnings: false,
      errors: true
    }
  },
  configureWebpack: {
    name: '测试模板',
    resolve: {
      alias: {
        '@': resolve('src')
      }
    }
  },
  chainWebpack (config) {
    config.module
      .rule('vue')
      .use('vue-loader')
      .loader('vue-loader')
      .tap(options => {
        options.compilerOptions.preserveWhitespace = true
        return options
      })
    config.module
      .rule('svg')
      .exclude.add(resolve('src/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
    config.plugins
      .delete('prefetch')
  }
}
